'
' DotNetNukeŽ - http://www.dotnetnuke.com
' Copyright (c) 2002-2006
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
'

Imports DotNetNuke
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Security.Membership
Imports System.Web.Compilation
Imports System.Data
Imports System.Reflection
Imports System.Collections.Generic

Namespace DotNetNuke.Modules.IWeb
    Partial Class IWeb_Edit
        Inherits DotNetNuke.Entities.Modules.PortalModuleBase
        Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try

                Dim IWEBMethodInfoList As New List(Of IWEBMethodInfo)
                IWEBMethodInfoList = IWEBMethods.GetMethodsInDatabase()

                If IWEBMethodInfoList.Count = 0 Then
                    Dim objIWEBMethods As New IWEBMethods()
                    objIWEBMethods.AddandDeleteMethods()
                End If

                If Not Page.IsPostBack Then

                    If Not IWebController.GetIWebSettings(PortalId, "SecurityKey") = "" Then
                        Me.txtSecurityKey.Text = IWebController.GetIWebSettings(PortalId, "SecurityKey").ToString()
                    Else
                        Me.txtSecurityKey.Text = ""
                    End If

                End If

            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub
        Protected Sub cmdBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdBack.Click
            Response.Redirect(NavigateURL())
        End Sub

        Protected Sub btnUpdateSettings_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdateSettings.Click
            Dim IWebInfo As New IWebInfo()

            IWebInfo.PortalID = PortalId
            IWebInfo.SettingID = "SecurityKey"
            IWebInfo.Setting = Me.txtSecurityKey.Text

            If IWebController.CheckIWebSettings(PortalId, "SecurityKey") > 0 Then
                IWebController.UpdateIWebSettings(IWebInfo)
            Else
                IWebController.InsertIWebSettings(IWebInfo)
            End If

        End Sub

        Protected Sub lnkRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRefresh.Click
            Dim objIWEBMethods As New IWEBMethods()
            objIWEBMethods.AddandDeleteMethods()
            Me.GVWebMethodSecurity.DataBind()
        End Sub

        Protected Sub ddlPortalList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPortalList.SelectedIndexChanged
            Me.GVWebMethodSecurity.DataBind()
        End Sub

        Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim intPortalID As Integer
            Dim strMethodName As String
            Dim strSecuritySetting As String

            Dim objDropDownList As DropDownList
            objDropDownList = CType(sender, DropDownList)

            intPortalID = Me.ddlPortalList.SelectedValue
            strMethodName = objDropDownList.ValidationGroup.ToString()
            strSecuritySetting = objDropDownList.SelectedItem.ToString()

            IWEBMethods.UpdateSecuritySetting(intPortalID, strMethodName, strSecuritySetting)

        End Sub
    End Class
End Namespace
